import { uniqBy } from 'lodash';
let parentNode = null
let node = null
let ashton = []
export function getParentNode(list, nodeId) {
  console.log(`要查询的节点-:------->${nodeId}------list->：`, list)
  for (let i = 0; i < list.length; i++) {
    if(!list || !nodeId || node) continue
    const item = list[i]
    if (item.parentId === -1) {
      ashton = []
    }
    const children = item.children
    if (children) {
      ashton.push(item.name)
      console.log(`item.id=nodeId---------->${item.id}<---->${nodeId}`)
      if (item.id == nodeId) {
        console.log("ok~~~~~~~~~!!");
        node = true
        uniqBy(ashton.concat([item.name]))
        break
      }else {
        parentNode = item
        getParentNode(item.children, nodeId)
      }
    }
  }
  if (!parentNode) { parentNode = "No ParentNode!" }
  return { parentNode: parentNode, node: node, ashton: ashton }
}